package troqler;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.validation.constraints.Max;

@Named
@RequestScoped
public class TreningsOktBean implements Serializable {

    private TreningsOkt data;
    @Inject
    private KategoriFinner kafinn;
    @Inject
    private OktTabell oktTabell;
    private boolean slett = false;
    private boolean endret = false;
   
    
    public TreningsOktBean(TreningsOkt okt)
    {
        this.data = okt;
    }
    

    public TreningsOkt getData()
    {
        return data;
    }
    public void setData(TreningsOkt data)
    {
        this.data = data;
    }

    public TreningsOktBean() {

        data = new TreningsOkt(-1);
        data.setKategori("");
        data.setDato(new Date());
    }

    public int getNr() {
        return data.getNr();
    }

    
    public boolean getSlett() {
        return slett;
    }

    public void setSlett(boolean slett) {
        this.slett = slett;
    }

    public String lagre() throws SQLException {
        if (data.getNr() == -1) {
            oktTabell.registrerNyOkt(data);
        }
        return "lagreOk";
    }
    public boolean getEndret()
    {
        return endret;
    }
    public void setEndret(boolean endret)
    {
        this.endret = endret;
    }
    public void endret()
    {
        endret = true;
    }
    
}
